use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::HullMovingAverage

///
///  参见[HMA](https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/hull-moving-average)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct HMA {
    ///1 signal
    /// When HMA value reverses upwards, gives full positive signal.
    /// When HMA value reverses downwards, gives full negative signal.
    /// Otherwise returns no signal.
    pub signal0: Option<IndicatorActionWrap>,

    ///     1 value
    /// HMA value
    /// Range of values is the same as the range of the source values.
    pub hma: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct HMAConfig {
    ///period: PeriodType
    ///HMA period. Default is 9.
    ///
    ///Range in [3; PeriodType::MAX).
    pub period: PeriodType,
    ///   left: PeriodType
    ///   Left lag for reverse point detection. Default is 3.
    ///   
    ///   Range in [1; PeriodType::MAX/2]
    pub left: PeriodType,
    /// right: PeriodType
    /// Right lag for reverse point detection. Default is 2.
    ///
    /// Range in [1; PeriodType::MAX/2].
    pub right: PeriodType,
    //source: Source
    //Source type of values. Default is Close
}

impl Default for HMAConfig {
    fn default() -> Self {
        Self {
            period: 9,
            left: 3,
            right: 2,
            //source: Source::TP,
        }
    }
}
